<template>
  <div class="elm-edit">
    <elm-page-bb>
      <div>
        <el-form ref="model" size="small" label-width="100px">
          <elm-row>
            <el-form-item label="开始时间" prop="start_time">
              <el-date-picker v-model="model.start_time" value-format="yyyy-MM-dd" type="date"
                              style="width: 100%"></el-date-picker>
            </el-form-item>
            <el-form-item label="结束时间" prop="end_time">
              <el-date-picker v-model="model.end_time" value-format="yyyy-MM-dd" type="date"
                              style="width: 100%"></el-date-picker>
            </el-form-item>
          </elm-row>
          <elm-row>
            <el-form-item label="备注">
              <el-input type="textarea" v-model="model.remark" :rows="2"></el-input>
            </el-form-item>
          </elm-row>
          <elm-row>
            <el-form-item label="附件">
              <elm-upload module_name="biz_plm_plan_stage_files" :rel_id="model.id" :multiple="false" :limit="10"  list-type="file" tip=""></elm-upload>
            </el-form-item>
          </elm-row>
        </el-form>
      </div>
      <template #bottom>
        <el-button type="success" size="small" @click="submit" model.>立即保存</el-button>
        <el-button size="small" @click="close">取消</el-button>
      </template>
    </elm-page-bb>
  </div>

</template>

<script>
export default {
  extends: elmVueBase,
  data() {
    return {
      model: {id:elm.newGuid(),plan_id: elm.dialog.request.plan_id}
    }
  },
  created() {
    this.getData();
  },
  methods: {
    async submit() {
      await this.$refs["model"].validate();
      var res = await elm.post('/business/plm/plan/stage/Upsert', this.model);
      if (res == true) {
        this.close();
        this.v('保存成功。');
        this.request.callVue.tablebinding();
      }
      else {
        this.error('保存失败，请稍后尝试。');
      }
    },
    async getData(){
      let res=await elm.post("business/plm/plan/stage/GetData",{plan_id:this.model.plan_id});
      if(res.length>0)
        this.model=res[0];
    }
  }
}
</script>